/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.orderoid.jsf;

import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ValueChangeEvent;
import javax.faces.event.ValueChangeListener;

/**
 *
 * @author Dahlia
 */
public class CommandeValueListener implements ValueChangeListener {

    private final String STATUT_REFUSE = "Refusée";

    @Override
    public void processValueChange(ValueChangeEvent event) throws AbortProcessingException {


        //access country bean directly
        /*
         * CountryBean country = (CountryBean)
         * FacesContext.getCurrentInstance().
         * getExternalContext().getSessionMap().get("country");
         *
         * country.setLocaleCode(event.getNewValue().toString());
         */
        CommandeController raisonRefus = (CommandeController) FacesContext.getCurrentInstance().
                getExternalContext().getSessionMap().get("raisonRefus");

        String strStatutCommande = event.getNewValue().toString();

        if (strStatutCommande.equals(STATUT_REFUSE)) {
            raisonRefus.setDisabled("false");
        }
    }
}
